/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ourgame.tankgame.bullet;

import com.ourgame.tankgame.attribute.BulletAttribute;
import com.jme3.bounding.BoundingBox;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import com.ourgame.tankgame.control.BulletControl;
import com.ourgame.tankgame.control.ControlsManager;
import com.ourgame.tankgame.exception.TankGameNullPointException;
import com.ourgame.tankgame.object.TankGameObject;
import gameutil.Role;

/**
 *
 * @author L
 */
public abstract class Bullet extends TankGameObject {

    private BulletAttribute bulletAttribute;
    BulletControl bulletControl;

    public Bullet(BulletAttribute bulletInfo, Spatial spatial) {
        super(spatial);
        this.bulletAttribute = bulletInfo;
        bulletControl = ControlsManager.getBulletControl(spatial, bulletInfo.getBulletMass());
        addControl(bulletControl);
    }

    public Bullet(Spatial shell, Role bulletRole) {
        super(shell);
        setName(bulletAttribute.getBulletName());
    }

    public BulletControl getBulletControl() {
        return bulletControl;
    }

    /**
     * @return the bulletAttribute
     */
    public BulletAttribute getBulletAttribute() {
        return bulletAttribute;
    }

    public void setBulletPower(int powerValue) {
        if (bulletAttribute != null) {
            bulletAttribute.setBulletPower(powerValue);
        } else {
            throw new TankGameNullPointException("bulletAttribute is null");
        }
    }

    public void setBulletSpeed(float speedValue) {
        if (bulletAttribute != null) {
            bulletAttribute.setBulletSpeed(speedValue);
        } else {
            throw new TankGameNullPointException("bulletAttribute is null");
        }
    }

    public abstract void setBulletDir(Vector3f vec);

    public abstract void setBulletPos(Vector3f vec);

    public abstract void setBulletRot(Quaternion rot);
}
